#ifndef _FMIADAPTER_H_
#define _FMIADAPTER_H_



#include "IEDEMCoupling.h"
#include "vectorMaths.h"


#include <fmilib.h>
#include <JM/jm_portability.h>
#include <FMI/fmi_zip_unzip.h>


#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <string.h>

#include <miniunz.h>

using namespace std;
using namespace NApiEDEM;


class CGeometry // A simple geometry class
{
public:
	// ID
	int         id;

	// Geometry properties
	double      mass;
	C3x3Matrix  momentOfInertia;

	// External forces
	C3dVector   force;
	C3dVector   torque;

	// Geometry accelerations & velocities
	C3dVector   acceleration;
	C3dVector   angularAcceleration;
	C3dVector   velocity;
	C3dVector   angularVelocity;

	// Geometry position
	C3dPoint    centerOfMass;
	C3dPoint    pointOfAction;
	C3x3Matrix  orientation;
	C3dVector   totalTranslation;
};

struct  CosimBody
{
	int id;
	double mass;
	string name;
	double momentOfInertia[3][3];
	int pos_x;
	int pos_y;
	int pos_z;
	int ort_x;
	int ort_y;
	int ort_z;
	int vel_x;
	int vel_y;
	int vel_z;
	int ang_vel_x;
	int ang_vel_y;
	int ang_vel_z;
	int fx;
	int fy;
	int fz;
	int tx;
	int ty;
	int tz;
};

struct FmiVariable
{
	string name;
	int valueReference;
	string causality;
};

class FMIAdapter
{
public:

	double  ENDTIME;

	FMIAdapter(string fmuFile , string spckFile);
	bool RunSimulation();

private:	
	string FMUFile;
	string FMUTempPath;
	string SpckFile;
	vector< CosimBody> getCosimBody();
};

C3x3Matrix ort2matrix(C3dVector ort);

#endif // _FMIADAPTER_H_



